home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_8.lha / 7_8 / 7_8a3.h < prev    next >
C/C++ Source or Header  |  1993-08-08  |  1KB  |  49 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. define gdlistdeclare(TYPE)            \
  6.    /* manage a doubly-linked list */        \
  7.    class gdlist(TYPE)                \
  8.    {                        \
  9. gdlink(TYPE) *last;            \
  10. gdlink(TYPE) *curr;            \
  11.                     \
  12.    public:                    \
  13. gdlist(TYPE)() { last = curr = 0; };    \
  14.                     \
  15. gdlist(TYPE)(TYPE a)            \
  16. { curr = 0; last = new gdlink(TYPE)(a);    \
  17.   last->next = last->prev = last;    \
  18. }                    \
  19.                     \
  20. int isempty() { return last != 0; }    \
  21.                     \
  22. void clear();                \
  23.                     \
  24. ~gdlist(TYPE)() { clear(); };        \
  25.                     \
  26. /* set current pointer to the */    \
  27. /* ends of the list */            \
  28. void reset() { curr = 0; }        \
  29.                     \
  30. /* move around the list, */        \
  31. /* leaving the links there */        \
  32. int next(TYPE &e);            \
  33. int prev(TYPE &e);            \
  34.                     \
  35. /* move around the list, */        \
  36. /* removing the links */        \
  37. int getnext(TYPE &e);            \
  38. int getprev(TYPE &e);            \
  39.                     \
  40. /* manipulate around the beginning */    \
  41. /* and end of the list */        \
  42. void insert(TYPE e);            \
  43. void append(TYPE e);            \
  44.                     \
  45. /* work around the current entry */    \
  46. void inserthere(TYPE e);        \
  47. void appendhere(TYPE e);        \
  48.    };
  49.